#-*- codeing = utf-8 -*-
#@Time : 2020/10/17 20:15
#@Author : 阳某
#@File : 读取文件.py
#@Software : PyCharm

import pandas as pd

df = pd.read_csv('./files/ratings.csv')
# 默认查看前5行数据
print(df.head())
# 查看数据的形状，返回行数，列数
print(df.shape)
# 查看列名列表
print(df.columns)
print(list(df.columns))
# 查看索引列表
print(df.index)
print(list(df.index))
# 查看每列的数据类型
print(df.dtypes)

# 读取txt文件，自己制定分隔符，列名
df1 = pd.read_csv('./files/access_pvuv.txt',sep='\t',header=None,names=['pdate','pv','uv'])
print(df1)
print(type(df1))

# 读取excel文件
df2 = pd.read_excel('./files/access_pvuv.xlsx')
print(df2)

# 读取mysql数据库
import pymysql
# conn = pymysql.connect(
#         host='127.0.0.1',
#         user='root',
#         password='',
#         database='test',
#         charset='utf8'
#     )
# mysql_page = pd.read_sql("select * from crazyant_pvuv", con=conn)
# print(mysql_page)